/*
 *  control.cpp
 *  projector
 *
 *  Created by Ilya Spivakov on 10/29/05.
 *  Copyright 2005 __MyCompanyName__. All rights reserved.
 *
 */

#include "control.h"
#include "song_widget.h"
#include <QDesktopWidget>
#include <QApplication>

ControlWidget::ControlWidget(QWidget *parent)
        : QWidget(parent)
{
    QDesktopWidget *desktop;
    Settings =new SettingsWidget();
    QLabel *urlLabel = new QLabel(this);
    urlLabel->setOpenExternalLinks(1);
    urlLabel->setTextInteractionFlags(Qt::LinksAccessibleByMouse);
    urlLabel->setText("This software is free and open source. If you can help in improving this program please visit  <a href=\"http://bibleprojector.sf.net\"> bibleprojector.servehttp.com</a>.");
    desktop= new QDesktopWidget();
    main_grid=new QGridLayout(this);
    tabs=new QTabWidget(this);
    BibleControlWidget=new BibleWidget;
    main_grid->addWidget(tabs,0,0);
    main_grid->addWidget(urlLabel,1,0,Qt::AlignHCenter);
    tabs->addTab(BibleControlWidget,"Russian Bible");
    RussianSongControlWidget = new song_widget(this,"./songs");
    tabs->addTab(RussianSongControlWidget,"Songs");


    //FreeTextControlWidget=new FreeTextWidget;
    //tabs->addTab(FreeTextControlWidget,"Free Text");
    Display1=new DisplayWidget(desktop->screen(3));


    tabs->addTab(Settings,"Settings");
    Display1->setGeometry(10,10,640,480);
    if (desktop->numScreens()>1)
    {

        if (desktop->isVirtualDesktop())
        {
            Display1->setGeometry(desktop->screen(0)->width()-100,200,100,100);
        }
        Display1->showFullScreen();
    }
    else
    {
        Display1->show();
    }
    setFocus();
    /*	connect(
    			FreeTextControlWidget,
    			SIGNAL(MainTextChanged(QString)),
    			Display1,
    			SLOT(SetMainText(QString ))
    			);*/
    connect(
        BibleControlWidget,
        SIGNAL(show_verse(QString , QString)),
        Display1,
        SLOT(SetAllText(QString ,QString )));
    connect(
        RussianSongControlWidget,
        SIGNAL(show_verse(QString , QString)),
        Display1,
        SLOT(SetAllText(QString ,QString )));
    connect(
        Settings,
        SIGNAL(FontChanged(QFont)),
        Display1,
        SLOT(NewFont(QFont)));
    connect(
        Settings,
        SIGNAL(WallpaperChanged(QString)),
        Display1,
        SLOT(NewWallpaper(QString)));

//	setWindowModality(Qt::ApplicationModal);


}

void ControlWidget::closeEvent(QCloseEvent *event)
{
    QCoreApplication::exit(0);
    event->accept();
}
